<?php

/**
 * Created by PhpStorm.
 * User: 小灰灰
 * Date: 2023-10-15
 * Time: 9:56:17
 * Info:
 */

namespace plugin\slide\app\model;

use think\Model;

class Slide extends Model
{

    protected $table = 'cmf_slide';

    /**
     * 自动时间戳类型
     * @var string
     */
    protected $autoWriteTimestamp = true;

    /**
     * 添加时间
     * @var string
     */
    protected $createTime = 'create_time';

    /**
     * 更新时间
     * @var string
     */
    protected $updateTime = 'update_time';

    public function slides($slideId = 0, $num = 3, $order = 'sort asc')
    {
        $list = Slide::where(function ($query) use ($slideId) {
            if ( ! empty($slideId)) {
                $query->where('slide_id', $slideId);
            }
        })->order($order)->limit($num)->select();

        return $list ?? [];
    }

}
